/*!
// DatatypeExp v1.0
// Copyright 2015 OrChange Inc. All rights reserved.
// Licensed under the MIT License.
*/
/*jslint vars: true, sloppy: true, nomen: true, plusplus: true */
/*global Exp: false */

/**
 * Boolean pattern expression object.
 *
 * @class NumberExp
 * @constructor
 * @param {string} exp
 */
expPattern.booleanExpPattern = /^!(true|false)?$/;
var BooleanExp = function BooleanExp(exp) {
	Exp.apply(this, arguments);

	if (expPattern.booleanExpPattern.test(exp)) {
		this.pattern = exp.substr(1);
	} else {
		throw new SyntaxError('Expression: "' + exp + '" is not a valid boolean pattern!');
	}
};
BooleanExp.prototype = new Exp();
BooleanExp.prototype.constructor = BooleanExp;

BooleanExp.prototype.$test = function (boolean) {
	if (typeof boolean !== 'boolean') {
		return false;
	}

	if (this.pattern === '') {
		return true;
	} else {
		return boolean.toString() === this.pattern;
	}
};
